﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;

namespace PowermateLights
{
    static class Program
    {
        private static PowermateLightTray powerTray;
        public static NotifyIcon trayIcon;
        private static ContextMenu trayMenu;
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            // Create a tray icon. In this example we use a
            // standard system icon for simplicity, but you
            // can of course use your own custom icon too.
            trayIcon = new NotifyIcon();
            trayIcon.Text = "Powermate light tray";
            //Set the initial icon - lets be optimistic that it is connected.
            trayIcon.Icon = Properties.Resources.connected;

            powerTray = new PowermateLightTray();

            // Create a simple tray menu with only one item.
            trayMenu = new ContextMenu();
            trayMenu.MenuItems.Add("Lights On", powerTray.OnLightOn);
            trayMenu.MenuItems.Add("Lights On Full", powerTray.OnLightFull);
            trayMenu.MenuItems.Add("Lights Off", powerTray.OnLightOff);
            trayMenu.MenuItems.Add("Settings", OnSettings);
            trayMenu.MenuItems.Add("Exit", OnExit);

            // Add menu to tray icon and show it.
            trayIcon.ContextMenu = trayMenu;
            trayIcon.Visible = true;
            Application.ApplicationExit += OnExit;
            Application.Run();
        }

        private static void OnExit(object sender, EventArgs e)
        {
            trayIcon.Dispose();
            //powerTray.Dispose();
            Application.Exit();
        }

        private static void OnSettings(object sender, EventArgs e)
        {
            Settings settings = new Settings();
            settings.Show();
        }

    }
}
